package com.example.swaggerdemo.controller;

import com.example.swaggerdemo.core.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@Api(tags = "系统管理")
@RestController
@RequestMapping("/api")
public class ApiController {

    @GetMapping("/time")
    public R time() {
        return R.ok().data("date:" + LocalDateTime.now());
    }

    @ApiOperation(value = "欢迎接口", notes = "备注: name->用户名")
    @GetMapping("/welcome")
    public R welcome(String name) {
        return R.ok().data("欢迎您:" + name);
    }

    @ApiOperation("Map数据")
    @GetMapping("/map")
    public ResponseEntity map(Integer age) {
        Map<String, Object> map = new HashMap<>(8);
        map.put("name", "chenzz");
        map.put("email", "cs.chenzz@qq.com");
        map.put("age", age);
        return ResponseEntity.ok(map);
    }

}
